import 'package:flutter/cupertino.dart';

extension WidgetExtension on Widget {
  // Add padding to all sides of the widget
  Widget padAll(double value) => Padding(padding: EdgeInsets.all(value), child: this);

  // Add symmetric padding to the widget
  Widget padSymmetric({double vertical = 0, double horizontal = 0}) => Padding(padding: EdgeInsets.symmetric(vertical: vertical, horizontal: horizontal), child: this);

  // Add only padding to the widget
  Widget padOnly({double left = 0, double top = 0, double right = 0, double bottom = 0}) => Padding(padding: EdgeInsets.only(left: left, top: top, right: right, bottom: bottom), child: this);

  // Add margin to all sides of the widget
  Widget marginAll(double value) => Container(margin: EdgeInsets.all(value), child: this);

  // Add symmetric margin to the widget
  Widget marginSymmetric({double vertical = 0, double horizontal = 0}) => Container(margin: EdgeInsets.symmetric(vertical: vertical, horizontal: horizontal), child: this);

  // Add only margin to the widget
  Widget marginOnly({double left = 0, double top = 0, double right = 0, double bottom = 0}) => Container(margin: EdgeInsets.only(left: left, top: top, right: right, bottom: bottom), child: this);

  // Constrain the max width of the widget
  Widget maxWidth(double value) => ConstrainedBox(constraints: BoxConstraints(maxWidth: value), child: this);

  // Constrain the max height of the widget
  Widget maxHeight(double value) => ConstrainedBox(constraints: BoxConstraints(maxHeight: value), child: this);

  // Constrain the min width of the widget
  Widget minWidth(double value) => ConstrainedBox(constraints: BoxConstraints(minWidth: value), child: this);

  // Constrain the min height of the widget
  Widget minHeight(double value) => ConstrainedBox(constraints: BoxConstraints(minHeight: value), child: this);

  /// expand
  Widget expand() => Expanded(child: this);

  /// borderRadius
  Widget borderRadius(double radius) => ClipRRect(borderRadius: BorderRadius.circular(radius), child: this);

  /// size
  Widget size({double? width, double? height}) => SizedBox(width: width, height: height, child: this);

  /// onTap
  Widget onTap(Function() onTap) => GestureDetector(onTap: onTap, child: this);
}

extension IntExtension on int {
  /// to vertical box
  Widget get toVerticalBox => SizedBox(height: toDouble());

  /// to horizontal box
  Widget get toHorizontalBox => SizedBox(width: toDouble());
}